#pragma once

#include <string>

#include <openssl/ossl_typ.h>
#include <openssl/pkcs12.h>
#include <openssl/pem.h>
#include <openssl/bio.h>

using namespace std;

class CMyRSA
{
public:
	CMyRSA(void);
public:
	~CMyRSA(void);

	static int HandleRsaEncrypt(char *&pEncryptBuf, unsigned int &uiEncryptLen, const char* pOrgBuf, unsigned int uiOrgLen, const string &csCertFilePath);

	static int RsaEncrypt(char *&pEncryptBuf, unsigned int &uiEncryptLen, const char* pOrgBuf, unsigned int uiOrgLen, const string &sEncrypt_list);

	static int RsaEncrypt(char *&pEncryptBuf,const char* src,const char* rsan,const char* rsae,const char*rsal);
 


protected:
	static void init();
	static int base64decode(unsigned char *dest, const unsigned char *src, int srclen);
	static int base64encode(unsigned char* dest,const unsigned char *data,	int input_length);
	static char symbl_value(char c);
	static void dbg_mem_info(const unsigned char* mem, int len, const char* fmt, ...);
	static int MGF1(unsigned char *mask, long len, const unsigned char *seed,long seedlen);
	static int sha1(const unsigned char * msg, unsigned int msg_len, unsigned char *digest);
	static char val2hex(int val);
	static void dump(int len, const unsigned char* str);
	static int rsaes_oaep_enc(const unsigned char * msg, unsigned int msg_len, const unsigned char * label, unsigned int label_len, RSA * key, unsigned char* output);

private:
	string m_sPriKeyPwd; 
};
